package com.itawei.d1_InetAddress;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class MyAddressInet {
    public static void main(String[] args) throws UnknownHostException {
    /*
        static InetAddress getByName(String host) 确定主机名称的IP地址。主机名称可以是机器名称，也可以是IP地址
        String getHostName()                      获取此IP地址的主机名
        String getHostAddress()                   返回文本显示中的IP地址字符串
    */
        //1.获取InetAddress对象 其实就是IP地址 ->代表电脑
        InetAddress address = InetAddress.getByName("192.168.38.226");
        InetAddress address2 = InetAddress.getByName("ZuoYou" );
        System.out.println(address2);
        System.out.println("=========");
        System.out.println(address);

        String name = address.getHostName();
        System.out.println(name);

        String hostAddress = address.getHostAddress();
        System.out.println(hostAddress);
    }
}
